package com.telra.app.server.data;

import java.text.DecimalFormat;

/**
 * Struct to store an aggregate view of orders by Category
 *
 * @author jamesarlet
 *
 */
public class OrderAggregate {

    private final static DecimalFormat fmt = new DecimalFormat("#,##0.00");
    private final static DecimalFormat i_fmt = new DecimalFormat("#,##0");


    private OrderEvent.Category category;
    private int count;
    private double sum;
    private double max;
    private double avg;

    public OrderAggregate(OrderEvent.Category category, int count, double sum, double max, double avg) {
        this.category = category;
        this.count = count;
        this.sum = sum;
        this.max = max;
        this.avg = avg;
    }

    public void setCategory(OrderEvent.Category category) {
        this.category = category;
    }
    public void setCount(int count) {
        this.count = count;
    }
    public void setSum(double sum) {
        this.sum = sum;
    }
    public void setMax(double max) {
        this.max = max;
    }
    public void setAvg(double avg) {
        this.avg = avg;
    }

    public OrderEvent.Category getCategory() {
        return this.category;
    }
    public int getCount() {
        return this.count;
    }
    public double getSum() {
        return this.sum;
    }
    public double getMax() {
        return this.max;
    }
    public double getAvg() {
        return this.avg;
    }

    public String toString() {
        return category +
                ", count=" + i_fmt.format(count) +
                ", sum=" + fmt.format(sum) +
                ", max=" + fmt.format(max) +
                ", avg=" + fmt.format(avg);
    }

}
